GetUserBySid Method
Syntax
GetUserBySid as P (userSid as C)
Arguments
- userSidCharacter
The SID of a user.
Returns
- userA WindowsServices::ActiveDirectory::User (use as type P)
Returns a WindowsServices::ActiveDirectory::User object. Check the domain object's CallResult to see if the method succeeds.
Description
Get a user by SID for a WindowsServices::ActiveDirectory::Domain object.
'The follow line assumes that the machine is joined to an Active Directory domain and is allow to query Active Directory. dim domain as WindowsServices::ActiveDirectory::Domain = new WindowsServices::ActiveDirectory::Domain() if .not. domain.CallResult.Success then ?"There was an error connecting to an Active Directory domain: " + domain.CallResult.Text + crlf() goto exitTestFunction end if ?"The domain name is " + domain.Name + crlf() dim userid as c = "JohnDoe" dim user as p = domain.getUser(userId) if .not. domain.CallResult.Success then ?"There was an error getting the user " + userId + ": " + domain.CallResult.Text + crlf() goto exitTestFunction end if ?user.Name + crlf() dim usersRoles as c = user.Roles dim userGuid as c = user.Guid dim userSid as c = user.Sid dim userFromGuid as p = domain.getUserByGuid(userGuid) if .not. domain.CallResult.Success then ?"There was an error getting the user " + userId + " by guid " + userGuid + ": " + domain.CallResult.Text + crlf() goto exitTestFunction end if ?userFromGuid.Name + crlf() dim userFromSid as p = domain.getUserBySid(userSid) if .not. domain.CallResult.Success then ?"There was an error getting the user " + userId + " by sid " + userSid + ": " + domain.CallResult.Text + crlf() goto exitTestFunction end if ?userFromSid.Name + crlf() exitTestFunction: